<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<html>
<head>
<link href="../common/common.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="../common/common.js"></script>
</head>
<style type="text/css">
<!--
.shy-table {
	border-top: 1px solid #CCCCCC;
	border-right: 1px solid #CCCCCC;
	border-bottom: 1px solid #CCCCCC;
}
.shy-table td{
	border-bottom: 1px solid #CCCCCC;
	border-left: 1px solid #CCCCCC;
}
.STYLE1{
	border:none;
}
-->
</style>
<body>
<div id="leftlayout">
<table style="width:99%">
	<tr valign="top">
		<td width="20%">
			<html:form action="systools/DbTableMainAction.do?method=dbTalbeDetailScreen">
			<table class="input-table" width="98%" align="center">
				<thead>
					<tr>
						<td>数据库表信息</td>
					</tr>
				</thead>
				<tr>
					<td><strong>Table：</strong>
					<html:select property="table" styleClass="textbox" onchange="selectChange(this)">
					<option selected value="">------表列表------</option>
						<c:forEach var="t" items="${TABLE_LIST}">
							<html:option value="${t }">${t }</html:option>
						</c:forEach>
					</html:select>
					</td>
				</tr>
				<tr>
					<td>${TABLE_NAME }</td>
			    </tr>
			</table>
		</html:form>
		</td>
		<td width="80%">
			<form name="hsql" method="post">
				<table class="input-table" width="98%" align="center">
					<thead>
						<tr>
							<td colspan="2">查询调试
							<div style="text-align: left; color: red"><html:errors />${ERRORS }</div>
							</td>
						</tr>
					</thead>
				<tr>
					<td colspan="2"><input type="radio" name="type" value="hql" class="textbox" />hql 
					<input type="radio" checked name="type" value="sql" class="textbox"/>标准sql</td>
				</tr>
				<tr>
						<td><strong>查询语句：</strong>
						</td>
						<td><input type="text" name="hsql" size="130" value="${SQL}" class="textbox"/>
						<input type="button" class="button" value="执行" onClick="formSubmit(this)" /></td>
					</tr>
				</table>
			</form>
		</td>
	</tr>
	<tr>
		<td colspan="2">
		<c:if test="${columnSize !=null }">
			<table class="shy-table" width="98%" align="center" cellspacing="0">
				<c:set var="flag" value="1"/>
				<c:forEach var='v' items="${value}">
					<c:choose>
					<c:when test="${flag eq 1}">
						<c:set var="flag" value="0"/>
						<tr height="40" bgcolor="#EEF3F5">
							<c:forEach var='cv' items="${v}">
							<td>${cv }</td>
						</c:forEach>
						</tr>
					</c:when>
					<c:otherwise>
						<tr height="30">
							<c:forEach var='cv' items="${v}">
								<td>${cv }</td>
							</c:forEach>
						</tr>
					</c:otherwise>
					</c:choose>
				</c:forEach>
			</table>
			</c:if>
			<c:if test="${!empty TABLE_DETAIL }">
			<form name="sqlinput" method="post" action="DbTableMainAction.do?method=selectOfSqlScreen&table=${TABLE_NAME}&colNum=${COL_NUM}">
			<table class="shy-table" width="98%" align="center" cellspacing="0">
			
<tr height="40" bgcolor="#EEF3F5">
					<td>字段名</td>
					<td>字段类型</td>
					<td>长度</td>
					<td>小数位数</td>
					<td>是否为NULL</td>
					<td>
					<select id="sqlType" name="sqlType">
						<option value="selectAll">Select *</option>
						<option value="selectCount">Select count(*)</option>
						<option value="create">Create</option>
					</select><input type="submit" class="button" value="生成"/>
					</td>
				</tr>
				<c:set var="col" value="0"></c:set>
				<c:forEach var='row' items="${TABLE_DETAIL}">
					<tr height="30">
						<td>${row[0] }</td>
						<td>${row[1] }</td>
						<td>${row[2] }</td>
						<td>${row[3] }</td>
						<td><c:if test="${row[4] eq 0 }"><font color="red">否</font></c:if>
						<c:if test="${row[4] eq 1 }">是</c:if></td>
						<td><input class="textbox" type="text" name="${col }" id="${col }" value=""></td>
						<c:set var="col" value="${col+1 }"></c:set>
					</tr>
				</c:forEach>
				<tr>
					<td colspan="5"></td>
				</tr>
			</table>
			</form>
			</c:if>
		</td>
	</tr>
</table>


</div>
</body>
<script type="text/javascript">
function selectChange(obj){
	obj.form.submit();
}
function formSubmit(obj){
  var f = obj.form
 	f.action="DbTableMainAction.do?method=excuteHsqlScreen";
 	f.submit();
}
</script>
</html>
